package com.xiaotu.test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.xiaotu.common.model.TvInfoSpiderTempModel;
import com.xiaotu.common.util.CacheHandler;
import com.xiaotu.common.util.UUIDUtils;
import com.xiaotu.server.service.guduo.SupplementGuDuoRecordService;

public class SupplementTvInfoSpiderTempData {
	
	
	@SuppressWarnings({ "resource", "unchecked" })
	public static void main(String[] args) {
		
		List<TvInfoSpiderTempModel> addList = new ArrayList<TvInfoSpiderTempModel>();
		
		//注入SupplementGuDuoRecordService
		SupplementGuDuoRecordService supplementGuDuoRecordService = (SupplementGuDuoRecordService) new ClassPathXmlApplicationContext("application-context.xml").getBean("supplementGuDuoRecordService"); 
		
		CacheHandler cacheHandler = (CacheHandler)new ClassPathXmlApplicationContext("application-context.xml").getBean("cacheHandler");
		
		//获取缓存数据
		Map<String, Object> hGetAll = cacheHandler.hGetAll("TV_INFO_SPIDER_TEMP_20190529",Map.class);
		
		for(Entry<String, Object> entry : hGetAll.entrySet()){
			
			Map<String,Object> everyMap = (Map<String,Object>)entry.getValue();
			
			String dataid = everyMap.get("tv_dataid").toString().equals("")==true?null:everyMap.get("tv_dataid").toString();
			//String dataid = everyMap.get("dataId").toString().equals("")==true?null:everyMap.get("dataId").toString();
			
			
			String tvname = everyMap.get("tvname").toString().equals("")==true?null:everyMap.get("tvname").toString();
			//String tvname = everyMap.get("tvName").toString().equals("")==true?null:everyMap.get("tvName").toString();
			
			
			String [] label = everyMap.get("label").toString().equals("")==true?null:everyMap.get("label").toString().split("/");
			//String [] label = everyMap.get("movieType").toString().equals("")==true?null:everyMap.get("movieType").toString().split("/");
			String [] director = everyMap.get("director").toString().equals("")==true?null:everyMap.get("director").toString().split("/");
			String [] actors = everyMap.get("actor").toString().equals("")==true?null:everyMap.get("actor").toString().split("/");
			//String [] actors = everyMap.get("actors").toString().equals("")==true?null:everyMap.get("actors").toString().split("/");
			Integer type = 6;
			String relasedate = everyMap.get("relasedate").toString().equals("")==true?null:everyMap.get("relasedate").toString();
			//String relasedate = everyMap.get("relaseDate").toString().equals("")==true?null:everyMap.get("relaseDate").toString();
			Integer supplement = null;
			
			addList.add(new TvInfoSpiderTempModel(
					UUIDUtils.getId(),
					null,dataid,tvname,
					label,director,actors,
					type,relasedate,supplement,
					null,
					"骨朵",
					System.currentTimeMillis()/1000
					));
		
		}
		
		supplementGuDuoRecordService.saveTvInfoSpiderTempData(addList);
		
	}
}
